using System;
using System.Collections.Generic;
using System.Text;

namespace DiceRoller.Util {

  public class RandomNumberGenerator {

    public RandomNumberGenerator() { }

    public int Next() {
      return getCurrentRNG().Next();
    }

    public int Next(int max) {
      return getCurrentRNG().Next(max);
    }

    public int Next(int min, int max) {
      return getCurrentRNG().Next(min, max);
    }

    private int getSeed(){
			  //System.Diagnostics.perf
      long baseSeed = DateTime.Today.Ticks;
      int seed;
      if(baseSeed>Int32.MaxValue){
        seed = Convert.ToInt32(baseSeed - Int32.MaxValue);
      }
      else if(baseSeed < Int32.MinValue) {
        seed = Convert.ToInt32(baseSeed - Int32.MinValue);
      }
      else {
        seed = Convert.ToInt32(baseSeed);
      }
      return seed;
    }

    private Random getCurrentRNG() {
      Random rng;
      int seed;

      seed = getSeed();
      rng = new Random(seed);
      return rng;
    }

  }
}
